-
Notifications
You must be signed in to change notification settings - Fork 25
CRE-1325 #1713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
👋 mchain0, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
✅ API Diff Results - No breaking changes |
| Err: fmt.Errorf("requested seqNum %d for executionID %s is greater than the number of observed don times %d", | ||
| req.SeqNum, req.WorkflowExecutionID, numObservedDonTimes), | ||
| }) | ||
| cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you want to achieve with this cancel? The SendRepsonse is a sync function that either succeeds or fails. Calling cancel() afterwards does not seem to do anything.
| return nil, nil | ||
| } | ||
|
|
||
| func (p *Plugin) Observation(_ context.Context, outctx ocr3types.OutcomeContext, query types.Query) (types.Observation, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this parent context be used?
| func (p *Plugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query) (types.Observation, error) { |
| // Don't block if receiver not ready, but check if context is actually expired | ||
| select { | ||
| case <-ctx.Done(): | ||
| // Context cancelled or deadline exceeded before send | ||
| default: | ||
| // Try once more without blocking | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just check for an error instead of using the channel mechanism:
| // Don't block if receiver not ready, but check if context is actually expired | |
| select { | |
| case <-ctx.Done(): | |
| // Context cancelled or deadline exceeded before send | |
| default: | |
| // Try once more without blocking | |
| } | |
| // Don't block if receiver not ready, but check if context is actually expired | |
| ctx.Err() |
But what is meant to happen here? Both cases are no-ops.
| ctx, cancel := context.WithDeadline(context.Background(), req.ExpiryTime()) | ||
| req.SendResponse(ctx, | ||
| Response{ | ||
| WorkflowExecutionID: req.WorkflowExecutionID, | ||
| SeqNum: req.SeqNum, | ||
| Timestamp: 0, | ||
| Err: fmt.Errorf("requested seqNum %d for executionID %s is greater than the number of observed don times %d", | ||
| req.SeqNum, req.WorkflowExecutionID, numObservedDonTimes), | ||
| }) | ||
| cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: @pavel-raykov - you can use anonymous closures to reduce scope of deferred actions:
| ctx, cancel := context.WithDeadline(context.Background(), req.ExpiryTime()) | |
| req.SendResponse(ctx, | |
| Response{ | |
| WorkflowExecutionID: req.WorkflowExecutionID, | |
| SeqNum: req.SeqNum, | |
| Timestamp: 0, | |
| Err: fmt.Errorf("requested seqNum %d for executionID %s is greater than the number of observed don times %d", | |
| req.SeqNum, req.WorkflowExecutionID, numObservedDonTimes), | |
| }) | |
| cancel() | |
| func() { | |
| ctx, cancel := context.WithDeadline(context.Background(), req.ExpiryTime()) | |
| defer cancel() | |
| req.SendResponse(ctx, | |
| Response{ | |
| WorkflowExecutionID: req.WorkflowExecutionID, | |
| SeqNum: req.SeqNum, | |
| Timestamp: 0, | |
| Err: fmt.Errorf("requested seqNum %d for executionID %s is greater than the number of observed don times %d", | |
| req.SeqNum, req.WorkflowExecutionID, numObservedDonTimes), | |
| }) | |
| } () |
CRE-1325
Adds deadline-aware timeout handling for channel operations, preventing indefinite blocking and silent message drops when requests expire.